package cms.rbac.service;

import cms.rbac.entity.Item;
import cms.rbac.entity.Permission;
import cms.rbac.entity.Role;
import cms.rbac.util.RbacException;


public interface RbacManager {

    Role createRole(String name);

    Permission createPermission(String name);

    boolean addRole(Role role);

    boolean addPermission(Permission permission);

    boolean removeRole(Role role);

    boolean removeAllRoles();

    boolean removePermission(Permission permission);

    boolean removeAllPermissions();

    int updateRole(Role role);

    int updatePermission(Permission permission);

    Role getRole(String name) throws RbacException;

    Permission getPermission(String name) throws RbacException;


    boolean addChild(Role parent, Permission child);

    boolean addChild(Permission parent, Permission child);

    boolean addChild(Role parent, Role child);

    boolean removeChild(Role parent, Permission child);

    boolean removeChild(Permission parent, Permission child);

    boolean removeChild(Role parent, Role child);

    boolean removeChild(Role parent);

    boolean removeChild(Permission parent);


//    boolean addRule(Rule rule);

    boolean checkAccess(int userId, String permissionName);

    boolean checkAccess(int userId, Permission permission);

    boolean assign(Permission permission, int userId);

    boolean assign(Role role, int userId);

    boolean revoke(Permission permission, int userId);

    boolean revoke(Role role, int userId);

    boolean revokeAll(int userId);

    Role[] getRolesByUser(int userId);

    Permission[] getPermissionsByRole(Role role);

    Permission[] getPermissionsByUser(int userId);


}
